package similan.br32;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;

public class OrganizationAutoCompleteTagConverter implements Converter {

	public Object getAsObject(FacesContext context, UIComponent component,
			String value) throws ConverterException {
		
		OrganizationAutoCompleteTag orgTag = new OrganizationAutoCompleteTag();
		orgTag.setName(value);
		
		return orgTag;
	}

	public String getAsString(FacesContext context, UIComponent component,
			Object obj) throws ConverterException {
		
		if(obj != null){
			  if(obj instanceof OrganizationAutoCompleteTag){
				  OrganizationAutoCompleteTag orgTag = (OrganizationAutoCompleteTag) obj;
				  return orgTag.getName();
				  
			  }
			}
			
			return null;
	}

}
